package dfbz.ArraytList;
import java.util.ArrayList;
import java.util.Collections;

public class doudizhu {
    //创建牌
    //打乱牌
    //发牌
    public static void main(String[] args) {
//        printPoke(createPoke());
        ArrayList<String> poke = createPoke();
        System.out.println("============================初始牌===============================");
        printPoke(poke);
        System.out.println();
        System.out.println();
        System.out.println("============================洗牌完毕===============================");
        Collections.shuffle(poke);
        printPoke(poke);
        //洗牌
        //发牌
        System.out.println();
        System.out.println("============================发牌完毕===============================");
        fapai(poke);

    }
    //定义一个打印牌的格式
    public static void printPoke(ArrayList<String> poker) {
        int length = poker.size();
        for (int i = 0; i < length; i++) {
            if (i%18==0) {
                System.out.println();
            }
            System.out.print(poker.get(i)+",");
        }
    }
    public static  ArrayList<String> createPoke(){
        //定义一个泛型的集合，用来储存花色和点数组合好的牌
        ArrayList<String> poke=new ArrayList<>();
        //定义花色数组和点数数组
        String[] huases = {"♠","♥","♣","♦"};
        String[] numbers = {"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
        poke.add("大王");
        poke.add("小王");
        //遍历两个数组将它门一一组合在一起，外层控制行数，内层控制点数
        for (int i = 0; i < huases.length; i++) {
            for (int j = 0; j < numbers.length; j++) {
                poke.add(huases[i]+numbers[j]);//将组合好的牌，添加到poke的集合里面
            }
        }
        return poke;
    }
    //发牌
    public static void fapai(ArrayList<String> poke1){
        ArrayList<String> palyer1=new ArrayList<>();
        ArrayList<String> player2=new ArrayList<>();
        ArrayList<String> player3=new ArrayList<>();
        ArrayList<String> diPai = new ArrayList<String>();
        int length=poke1.size();
        for (int i = 0; i <length; i++) {
            if(i>50){
                diPai.add(poke1.get(i));
            }else if(i%3==0){
                palyer1.add(poke1.get(i));
            }else if(i%3==1){
              player2.add(poke1.get(i));
            }else if(i%3==2){
                player3.add(poke1.get(i));
            }
        }
        System.out.println(palyer1);
        System.out.println(player2);
        System.out.println(player3);
        System.out.println(diPai);
    }
}
